﻿//获取Token参数
	var Request = new Object();
	Request = GetRequest();
	var token= Request['Token'];
	var basePath="";
	
$(document).ready(function(){
	$('div.menu_list a_gray_yell:empty').remove();
	
//	tick();
	basePath = $("#basePath").attr("value");
	$('#setPwdForm input').focusout(trimkeyup);
	
	token=$('#token').attr("value");
	
	$("#layout").css('margin','0 auto');
//	$('#tt').tabs('add',{  
//        title:'欢迎',    
//        content:'<img src="'+basePath+'images/hello.jpg" />'
//    });  
});

function addTab(title, href){ 
	
	$.getJSON('action/master/usermanage/isLogin.json?Token='+token+'&rnd='+Math.random(),
			function(data){
		if(data.isLogin!=null&&!data.isLogin){
			var v=document.getElementById("base").getAttribute("href");
			window.location.href=document.getElementById("base").getAttribute("href");
		}else
		{
			 var tt = $('#tt');  
			    
			    if (tt.tabs('exists', title)){//如果tab已经存在,则选中并刷新该tab          
			        tt.tabs('select', title);  
			       // refreshTab({tabTitle:title,url:href});  
			    } else {  
			        if (href){  
			            var content = '<iframe scrolling="auto" frameborder="0"  src="'+href+'" style="width:100%;height:100%;"></iframe>';  
			        } else {  
			            var content = '未实现';  
			        }  
			        tt.tabs('add',{  
			            title:title,  
			            closable:true,  
			            content:content
			        }); 
			    }  
		}
	}
	);
   
} 

/**     
 * 刷新tab 
 * @cfg  
 *example: {tabTitle:'tabTitle',url:'refreshUrl'} 
 *如果tabTitle为空，则默认刷新当前选中的tab 
 *如果url为空，则默认以原来的url进行reload 
 */  
function refreshTab(cfg){  
    var refresh_tab = cfg.tabTitle?$('#tabs').tabs('getTab',cfg.tabTitle):$('#tabs').tabs('getSelected');  
    if(refresh_tab && refresh_tab.find('iframe').length > 0){  
    var _refresh_ifram = refresh_tab.find('iframe')[0];  
    var refresh_url = cfg.url?cfg.url:_refresh_ifram.src;  
    //_refresh_ifram.src = refresh_url;  
    _refresh_ifram.contentWindow.location.href=refresh_url;  
    }  
}  

function loginout()
{
	$.messager.confirm('提示', "确定要退出系统吗？", function(r){
		if (r)
		{
			$.getJSON('action/master/usermanage/loginout.json?Token=' + token,
					function(data){});
			window.location=basePath;
		}
			
		else
			return false;
	});
}

function showLocale(objD)
{
	var str,colorhead,colorfoot;
	var yy = objD.getYear();
	if(yy<1900) yy = yy+1900;
	var MM = objD.getMonth()+1;
	if(MM<10) MM = '0' + MM;
	var dd = objD.getDate();
	if(dd<10) dd = '0' + dd;
	var hh = objD.getHours();
	if(hh<10) hh = '0' + hh;
	var mm = objD.getMinutes();
	if(mm<10) mm = '0' + mm;
	var ss = objD.getSeconds();
	if(ss<10) ss = '0' + ss;
	var ww = objD.getDay();
	if  ( ww==0 )  colorhead="<font>";
	if  ( ww > 0 && ww < 6 )  colorhead="<font>";
	if  ( ww==6 )  colorhead="<font >";
	if  (ww==0)  ww="星期日";
	if  (ww==1)  ww="星期一";
	if  (ww==2)  ww="星期二";
	if  (ww==3)  ww="星期三";
	if  (ww==4)  ww="星期四";
	if  (ww==5)  ww="星期五";
	if  (ww==6)  ww="星期六";
	colorfoot="</font>"
	str = colorhead + yy + "-" + MM + "-" + dd + colorfoot;
	return(str);
}
function tick()
{
	var today;
	today = new Date();
	document.getElementById("localtime").innerHTML = showLocale(today);
	window.setTimeout("tick()", 1000);
}
function trimkeyup(e) {
    lucene_objInput = $(this);
    if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13) {
        var im = $.trim(lucene_objInput.val());
        lucene_objInput.val(im); 
    }
}
//修改密码
function setPWD(){  
	$("#updateForm").attr("action","action/master/usermanage/setPWD.json?Token=" + token+"&rnd="+Math.random());
	openDialog('修改密码','pwdUpdateDig','','pwdUpdateForm',{'height': 250,'width':380,'draggable':false,clearForm:false},
		function(){
			 	$("#updateDig").dialog('close');
			});
//	$("#setPwdDig").dialog('open');
} 